#ifndef __COMTIMER_H
#define __COMTIMER_H

#include <sys/timerfd.h>
#include <time.h>
#include <sys/epoll.h>
#include <unistd.h>
#include "ComLog.h"

#define MAX_TIMER_NUM (20)

#ifdef __cplusplus
extern "C"
{
#endif
typedef void (*TimerCallback)(void *data);

typedef struct TimerEvent_t
{   
    int timerfd; //定时器
    int valid;   //是否使用
    TimerCallback cb; //定时器回调
    void *data; //自定义数组
    
}TimerEvent;

extern TimerEvent timerArray[MAX_TIMER_NUM];

//>=0 成功返回定时器句柄
int ComTimerAdd(TimerCallback cb, int mstimer , int repeat, void *data);
//删除某个定时器
int ComTimerDel(int timerfd);
//定时器调度
int ComTimerSchedule();
//关闭整个定时器
int ComTimerClose();



#ifdef __cplusplus
}
#endif

#endif